﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Bamboo.Utils
{
    /// <summary>
    /// Key-Value型简单数据库实现
    /// </summary>
    public class KeyValueDb
    {
        Dictionary<string, string> _data = new Dictionary<string, string>(10240);

        public void SetValue<T>(string key, T value)
        {
            lock(this)
            {
                _data[key] = value.ToString();
            }
        }

        public bool TryGetValue(string key, out string value)
        {
            lock(this)
            {
                if (_data.TryGetValue(key, out value))
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }
        }

        public void Save(string filename)
        {

        }
    }
}
